package com.leetcode.LC;

public class LC190 {
    // you need treat n as an unsigned value
    public int reverseBits(int n) {

        int rs = 0;
        for (int i = 0; i < 32; i++) {//32位
            //如果此位是1的话，颠倒这个位在32位数中的位置
            if ((n & 1) == 1) {
                rs = rs + (1 << (32 - i - 1));
            }
            //向右移一位，遍历32遍即可判断所有位
            n >>= 1;

        }
        return rs;
    }

    public static void main(String[] args) {
        System.out.println(new LC190().reverseBits(43261596));
        System.out.println(1 << 3);
    }
}
